<?php
	include "../../public/commom/config.php";
	include "../lock1.php";	
	include "../../public/commom/commom.php";
	
	$id = 0;
	if($_GET) {
		$id = $_GET["id"];
		
		$sql = "SELECT * FROM advert where id = $id";
		
		$result = mysqli_query($conn, $sql);
		
		while($row = mysqli_fetch_array($result)) {
			$pos = $row["pos"];
			$rul = $row["rul"];
			$img = $row["img"];
		}
	}
?>

<!DOCTYPE html>
<html>
	
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="../public/css/index.css"/>
	</head>
	
	<body>
		<div class="container">
			<form action="xiugai1.php" method="post" enctype="multipart/form-data">
				<div class="form-group">
					<label>
						序号：
						<select class="form-control" name="pos">
							<?php
								switch($pos) {
									case 0:
										echo "<option value='0' selected>0</option>
										<option value='1'>1</option>";
									break;
									case 1:
										echo "<option value='0'>0</option>
										<option value='1' selected>1</option>";
									break;
								}
								
								mysqli_close($conn);
							?>
						</select>
					</label>
				</div>
				<div class="form-group">
					<label>
						RUL：
						<input type="text" class="form-control" name="rul" value="<?php echo $rul; ?>" autocomplete="off" />
					</label>
				</div>
				原图：
				<div class="form-group">
					<img src="<?php echo $imgPathThumb . $img; ?>"/>
				</div>
				<div class="form-group">
					<label>
						上传图片：
						<input type="file" name="img" accept="image/gif, image/jpeg, image/png, image/jpg, image/webp">
					</label>
				</div>
				<input type="hidden" name="id" value="<?php echo $id?>" />
				<input type="hidden" name="pimg" value="<?php echo $img?>" />
				<input type="submit" class="btn btn-primary" value="修改"/>
			</form>
		</div>
	</body>
	
</html>